/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package domain.impl;

import domain.DocumentRootHistory;
import domain.DomainPackage;
import domain.SystemHistory;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Document Root History</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link domain.impl.DocumentRootHistoryImpl#getSystemHistory <em>System History</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DocumentRootHistoryImpl extends EObjectImpl implements DocumentRootHistory {
	/**
	 * The cached value of the '{@link #getSystemHistory() <em>System History</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getSystemHistory()
	 * @generated
	 * @ordered
	 */
	protected SystemHistory systemHistory;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DocumentRootHistoryImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return DomainPackage.Literals.DOCUMENT_ROOT_HISTORY;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public SystemHistory getSystemHistory() {
		return systemHistory;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetSystemHistory(SystemHistory newSystemHistory, NotificationChain msgs) {
		SystemHistory oldSystemHistory = systemHistory;
		systemHistory = newSystemHistory;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, DomainPackage.DOCUMENT_ROOT_HISTORY__SYSTEM_HISTORY, oldSystemHistory, newSystemHistory);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setSystemHistory(SystemHistory newSystemHistory) {
		if (newSystemHistory != systemHistory) {
			NotificationChain msgs = null;
			if (systemHistory != null)
				msgs = ((InternalEObject)systemHistory).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - DomainPackage.DOCUMENT_ROOT_HISTORY__SYSTEM_HISTORY, null, msgs);
			if (newSystemHistory != null)
				msgs = ((InternalEObject)newSystemHistory).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - DomainPackage.DOCUMENT_ROOT_HISTORY__SYSTEM_HISTORY, null, msgs);
			msgs = basicSetSystemHistory(newSystemHistory, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, DomainPackage.DOCUMENT_ROOT_HISTORY__SYSTEM_HISTORY, newSystemHistory, newSystemHistory));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case DomainPackage.DOCUMENT_ROOT_HISTORY__SYSTEM_HISTORY:
				return basicSetSystemHistory(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case DomainPackage.DOCUMENT_ROOT_HISTORY__SYSTEM_HISTORY:
				return getSystemHistory();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case DomainPackage.DOCUMENT_ROOT_HISTORY__SYSTEM_HISTORY:
				setSystemHistory((SystemHistory)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case DomainPackage.DOCUMENT_ROOT_HISTORY__SYSTEM_HISTORY:
				setSystemHistory((SystemHistory)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case DomainPackage.DOCUMENT_ROOT_HISTORY__SYSTEM_HISTORY:
				return systemHistory != null;
		}
		return super.eIsSet(featureID);
	}

} //DocumentRootHistoryImpl
